import socket
import time

# 创建 socket 对象
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# server_socket.close()
# 获取本地主机名
host = '169.254.109.175'
print(host)
# 设置一个端口
port = 62021

# 绑定端口
server_socket.bind((host, port))

# 设置最大连接数，超过后排队
server_socket.listen(5)
try:

    # while True:
        # 接受一个新连接
        client_socket, addr = server_socket.accept()

        # # 接收客户端发送的数据
        # received_message = client_socket.recv(1024).decode()

        # 打印接收到的数据
        # print("服务器收到：", received_message)

        # # 发送一些数据到客户端
        # message = "Hello, Client!"
        # client_socket.send(message.encode())
        r_msg=client_socket.recv(15)
        t=float(r_msg.decode())
        print(t)
        print(time.time()-t)
        # 关闭客户端的连接
        # client_socket.close()
except Exception as e:
    print(e)
    server_socket.close()
    # server_socket.detach()
